********************************************************************************
*Table B1; Panel A; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



drop if mothers_age<24
drop if mothers_age>30

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panela_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

drop if mothers_age<24
drop if mothers_age>30

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panela_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel A; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



drop if mothers_age<24
drop if mothers_age>30

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panela_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

drop if mothers_age<24
drop if mothers_age>30

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panela_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel B; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



keep if tbo==1


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelb_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

keep if tbo==1


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelb_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel B; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


keep if tbo==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelb_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

keep if tbo==1


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelb_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel C; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks_full, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelc_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks_full, clear

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelc_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel C; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks_full, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelc_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks_full, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelc_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/



********************************************************************************
*Table B1; Panel D; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



gen pop_blacks=1 if mom_birth_state==17|mom_birth_state==13|mom_birth_state==22|mom_birth_state==12|mom_birth_state==6
drop if pop_blacks==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneld_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

gen pop_blacks=1 if mom_birth_state==17|mom_birth_state==13|mom_birth_state==22|mom_birth_state==12|mom_birth_state==6
drop if pop_blacks==1

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneld_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel D; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



gen pop_blacks=1 if mom_birth_state==17|mom_birth_state==13|mom_birth_state==22|mom_birth_state==12|mom_birth_state==6
drop if pop_blacks==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneld_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

gen pop_blacks=1 if mom_birth_state==17|mom_birth_state==13|mom_birth_state==22|mom_birth_state==12|mom_birth_state==6
drop if pop_blacks==1

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneld_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel E; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panele_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panele_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel E; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panele_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panele_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel F; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelf_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelf_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel F; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37  $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelf_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelf_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel G; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

ivregress 2sls newbw2500 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelg_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui ivregress 2sls newbw2500 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state

local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelg_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel G; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

ivregress 2sls newpretermLT37 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelg_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui ivregress 2sls newpretermLT37 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state

local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelg_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel H; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelh_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelh_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel H; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelh_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelh_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel I; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



egen birth_month_year=group(birth_month year)

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by  i.birth_month_year i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneli_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

egen birth_month_year=group(birth_month year)


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.birth_month_year i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneli_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel I; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear



egen birth_month_year=group(birth_month year)

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by  i.birth_month_year i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneli_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

egen birth_month_year=group(birth_month year)


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.birth_month_year i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneli_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/






********************************************************************************
*Table B1; Panel J; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


egen bybybirthstate=group(by mom_birth_state)


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(bybybirthstate)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelj_c1", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

egen bybybirthstate=group(by mom_birth_state)


preserve
bsample, cluster(bybybirthstate)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelj_c1, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel J; Column 2 
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


egen bybybirthstate=group(by mom_birth_state)


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(bybybirthstate)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelj_c2", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear

egen bybybirthstate=group(by mom_birth_state)


preserve
bsample, cluster(bybybirthstate)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelj_c2, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*whites*whites*whites*whites*whites*whites*whites*whites*whites*whites*whites*
********************************************************************************
********************************************************************************
*Table B1; Panel A; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



drop if mothers_age<24
drop if mothers_age>30

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panela_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

drop if mothers_age<24
drop if mothers_age>30

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panela_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel A; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



drop if mothers_age<24
drop if mothers_age>30

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panela_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

drop if mothers_age<24
drop if mothers_age>30

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panela_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel B; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



keep if tbo==1


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelb_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

keep if tbo==1


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelb_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel B; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


keep if tbo==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelb_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

keep if tbo==1


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelb_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel C; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites_full, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelc_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites_full, clear

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelc_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel C; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites_full, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelc_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites_full, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelc_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/



********************************************************************************
*Table B1; Panel D; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



gen pop_whites=1 if mom_birth_state==6|mom_birth_state==48|mom_birth_state==39|mom_birth_state==17|mom_birth_state==42
drop if pop_whites==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneld_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

gen pop_whites=1 if mom_birth_state==6|mom_birth_state==48|mom_birth_state==39|mom_birth_state==17|mom_birth_state==42
drop if pop_whites==1

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneld_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel D; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



gen pop_whites=1 if mom_birth_state==6|mom_birth_state==48|mom_birth_state==39|mom_birth_state==17|mom_birth_state==42
drop if pop_whites==1

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneld_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

gen pop_whites=1 if mom_birth_state==6|mom_birth_state==48|mom_birth_state==39|mom_birth_state==17|mom_birth_state==42
drop if pop_whites==1

preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.year i.birth_month i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneld_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel E; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
****************************************************************************************************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panele_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panele_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel E; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
****************************************************************************************************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panele_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var eitcby_kid2 yearsfcor yearsflr i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panele_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel F; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelf_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelf_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel F; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37  $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelf_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state Tax AP ACS TA
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelf_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Table B1; Panel G; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

ivregress 2sls newbw2500 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelg_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui ivregress 2sls newbw2500 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state

local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelg_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel G; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

ivregress 2sls newpretermLT37 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelg_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui ivregress 2sls newpretermLT37 $treat_var (elig00=simu00) $state_var i.age_cat i.tbo i.male i.year i.birth_month  i.division#c.by i.by i.mom_birth_state

local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelg_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Table B1; Panel H; Column 3 
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelh_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelh_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel H; Column 4 
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelh_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear



preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.mom_birth_state#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_b1_panelh_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel I; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



egen birth_month_year=group(birth_month year)

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by  i.birth_month_year i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneli_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

egen birth_month_year=group(birth_month year)


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.birth_month_year i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneli_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Table B1; Panel I; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear



egen birth_month_year=group(birth_month year)

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by  i.birth_month_year i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_paneli_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

egen birth_month_year=group(birth_month year)


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.birth_month_year i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_paneli_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/






********************************************************************************
*Table B1; Panel J; Column 3 
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


egen bybybirthstate=group(by mom_birth_state)


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(bybybirthstate)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelj_c3", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

egen bybybirthstate=group(by mom_birth_state)


preserve
bsample, cluster(bybybirthstate)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelj_c3, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/







********************************************************************************
*Table B1; Panel J; Column 4 
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear


egen bybybirthstate=group(by mom_birth_state)


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state, cluster(bybybirthstate)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_b1_panelj_c4", replace
forvalues i=1/500 {
use $data/estimation_sample_whites, clear

egen bybybirthstate=group(by mom_birth_state)


preserve
bsample, cluster(bybybirthstate)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male i.year i.birth_month i.division#c.by i.by i.mom_birth_state 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_b1_panelj_c4, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/


